Repository navigation
Correct near-start peak guesses regardless of input order - #680
Merged
Merged
Conversation
tompollard
approved these changes
Nov 24, 2026
tompollard
left a comment
Member
There was a problem hiding this comment.
Reviewed at fb7c5de. The change corrects each near-start guess independently while preserving input order and sorted-input behavior. The added tests cover unsorted and duplicate guesses across all peak directions and a written/read WFDB record. I ran the processing tests locally (151 passed), and all PR checks are green. Looks good to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
correct_peaks()can return a negative index for a valid near-start guess when that guess follows a later one in the input array. The boundary-adjustment loop stops at the first guess outside the near-start window, leaving subsequent early guesses unadjusted.For a length-30 signal with maxima at samples 0 and 20:
Skip individual later guesses instead of ending the boundary-adjustment loop. Preserve input order and duplicates. This extends the near-start correction from #613 to unsorted inputs without changing sorted-input behavior.
Tests cover all four direction options, duplicate guesses, sorted controls, unchanged input, and a written/read digital WFDB record passed to the public API. The 17 added cases produce 13 failures and 4 passing controls on the unchanged code.
Validation on current main 05db3a2 plus this patch:
tests/test_processing.py: 151 passed on Python 3.12.16.-W --keep-goingpassed.Earlier same-file validation: 113 peak tests passed on Python 3.10.12; 4,000 seeded permutation checks and 4,000 sorted baseline/fixed equivalence checks passed. The full repository suite and remote CI have not been verified. These tests check index correction, not clinical detection accuracy.
AI assistance was used to develop and test this change. Independent review has not been completed.